/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package _4_Mapper;

import _3_Object.UserProfileObject;
import _5_DB.ConnectDB;
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;

/**
 *
 * @author DOM
 */
public class UserProfileMapper {
    public static UserProfileObject upo(int uid)
    {
        UserProfileObject u = new UserProfileObject();
        try{
            ConnectDB db = new ConnectDB();
            Connection con = db.getConnection();
            
            CallableStatement proc = null;
            proc = con.prepareCall("{call procLayUser(?)}");
            
            proc.setInt(1, uid);
            
            
            ResultSet rs = proc.executeQuery();
            if(rs.next())
            {
                u.setuID(rs.getInt("uID"));
                u.setName(rs.getString("name"));
                u.setBirth(rs.getString("birth"));
                u.setSex(rs.getInt("sex"));
                u.setEmail(rs.getString("email"));
                u.setPhone(rs.getString("phone"));
                u.setAbout(rs.getString("about"));
                u.setCreatedate(rs.getString("createdate"));
                u.setNick(rs.getString("nick"));
                u.setAvatar(rs.getString("avatar"));
                u.setSetting(rs.getString("setting"));
                u.setUrl(rs.getString("url"));
            }
        }
         catch(SQLException ex)
       {
           System.out.println(ex.getMessage());
       }
       return u;
    }
}
